package com.xhs.runner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.net.InetAddress;

/**
 * @desc: 启动控制台打印信息
 * @projectName: auto-number
 * @author: xhs
 * @date: 2025-03-11 周二 14:02
 * @version: JDK 21
 */
@Slf4j
@Component
public class AppRunner implements CommandLineRunner {

    @Value("${server.port}")
    private String port;

    @Override
    public void run(String... args) throws Exception {
        InetAddress addr = InetAddress.getLocalHost();
        String ipAddr = addr.getHostAddress();
        log.info("\n--------------------------------------------------------------------" +
                        "\nApplication is running! Access URLs:" +
                        "\nLocal:    http://localhost:{}" +
                        "\nHost:     http://{}:{}" +
                        "\n--------------------------------------------------------------------",
                port, ipAddr, port);
    }
}
